<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>PhysiTrack: D:/physi-tracklast/01/Android/PhysiTrack/src/ro/ubbcluj/android/PhysiTrack/PhysiTrackActivity.java Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">PhysiTrack
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">D:/physi-tracklast/01/Android/PhysiTrack/src/ro/ubbcluj/android/PhysiTrack/PhysiTrackActivity.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_physi_track_activity_8java.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="keyword">package </span>ro.ubbcluj.android.PhysiTrack;
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="keyword">import</span> helper.FileIOHelper;
<a name="l00005"></a>00005 <span class="keyword">import</span> image.Analyzer;
<a name="l00006"></a>00006 <span class="keyword">import</span> image.OwnImage;
<a name="l00007"></a>00007 <span class="keyword">import</span> java.io.IOException;
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="keyword">import</span> process.ImageErrorException;
<a name="l00010"></a>00010 <span class="keyword">import</span> process.ProcIm;
<a name="l00011"></a>00011 <span class="keyword">import</span> android.app.Activity;
<a name="l00012"></a>00012 <span class="keyword">import</span> android.app.AlertDialog;
<a name="l00013"></a>00013 <span class="keyword">import</span> android.app.Dialog;
<a name="l00014"></a>00014 <span class="keyword">import</span> android.content.Context;
<a name="l00015"></a>00015 <span class="keyword">import</span> android.content.DialogInterface;
<a name="l00016"></a>00016 <span class="keyword">import</span> android.content.Intent;
<a name="l00017"></a>00017 <span class="keyword">import</span> android.hardware.Camera;
<a name="l00018"></a>00018 <span class="keyword">import</span> android.hardware.Camera.PreviewCallback;
<a name="l00019"></a>00019 <span class="keyword">import</span> android.os.Bundle;
<a name="l00020"></a>00020 <span class="keyword">import</span> android.util.Log;
<a name="l00021"></a>00021 <span class="keyword">import</span> android.view.SurfaceHolder;
<a name="l00022"></a>00022 <span class="keyword">import</span> android.view.SurfaceView;
<a name="l00023"></a>00023 <span class="keyword">import</span> android.view.View;
<a name="l00024"></a>00024 <span class="keyword">import</span> android.view.View.OnClickListener;
<a name="l00025"></a>00025 <span class="keyword">import</span> android.view.Window;
<a name="l00026"></a>00026 <span class="keyword">import</span> android.view.WindowManager;
<a name="l00027"></a>00027 <span class="keyword">import</span> android.widget.Button;
<a name="l00028"></a>00028 <span class="keyword">import</span> android.widget.EditText;
<a name="l00029"></a>00029 <span class="keyword">import</span> android.widget.LinearLayout;
<a name="l00030"></a>00030 <span class="keyword">import</span> android.widget.TextView;
<a name="l00031"></a>00031 
<a name="l00033"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">00033</a> <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a> <span class="keyword">extends</span> Activity {
<a name="l00034"></a>00034 
<a name="l00035"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a9ae029040989828ac44bdc544e3c0d14">00035</a>         <span class="keyword">private</span> Context <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a9ae029040989828ac44bdc544e3c0d14">context</a> = <span class="keyword">this</span>;
<a name="l00036"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a4c5e235b8006f00cc5c3b9cf6cfd287c">00036</a>         <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a4c5e235b8006f00cc5c3b9cf6cfd287c">TAG</a> = <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.class.getSimpleName();
<a name="l00037"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a785d9fc51a9c8c87240c4ae205059286">00037</a>         <span class="keyword">private</span> SurfaceView <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a785d9fc51a9c8c87240c4ae205059286">preview</a> = null;
<a name="l00038"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7d8d556b1784c753d9eb8a00d17a1f91">00038</a>         <span class="keyword">private</span> SurfaceHolder <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7d8d556b1784c753d9eb8a00d17a1f91">previewHolder</a> = null;
<a name="l00039"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">00039</a>         <span class="keyword">private</span> Camera <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a> = null;
<a name="l00040"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#afda4399ea9ae19db25f1e8f46d4dc39d">00040</a>         <span class="keyword">private</span> <span class="keywordtype">boolean</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#afda4399ea9ae19db25f1e8f46d4dc39d">inPreview</a> = <span class="keyword">false</span>;
<a name="l00041"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a865e52bbd221d0d65db95fd6cd546cc1">00041</a>         <span class="keyword">private</span> <span class="keywordtype">boolean</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a865e52bbd221d0d65db95fd6cd546cc1">paramsSet</a>;
<a name="l00042"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a58f4e0f0217f5e433a17b783685142a1">00042</a>         <span class="keyword">private</span> <span class="keywordtype">boolean</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a58f4e0f0217f5e433a17b783685142a1">isRunning</a>;
<a name="l00043"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a617b59df0d824c57437a251319483107">00043</a>         <span class="keyword">private</span> EditText <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a73c500622aa06734e6fad1ffba8f6658">text1</a>, <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a617b59df0d824c57437a251319483107">text2</a>;
<a name="l00044"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ab94b854437cfeb03989d7a6f56fe26ec">00044</a>         <span class="keyword">private</span> TextView <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ab94b854437cfeb03989d7a6f56fe26ec">velText</a>, <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7b5933e7c10aa164e811c74740d75cca">accText</a>;
<a name="l00045"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a03d60fc5556bf34d1a74ac507d2d7010">00045</a>         <span class="keyword">private</span> <span class="keywordtype">double</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#abca21fd83ce7631d66f85a7247ac59c3">sigmaM</a>, <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a03d60fc5556bf34d1a74ac507d2d7010">sigmaW</a>;
<a name="l00046"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a6fe7bd9c0bde97a16cea6146278551d2">00046</a>         <span class="keyword">private</span> <span class="keywordtype">long</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a6fe7bd9c0bde97a16cea6146278551d2">timestamp</a>;
<a name="l00047"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">00047</a>         <span class="keyword">private</span> <a class="code" href="classimage_1_1_analyzer.html">Analyzer</a> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a>;
<a name="l00048"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a3ff8fd51656a9b577fda3b6e6dfe2719">00048</a>         <span class="keyword">private</span> <span class="keywordtype">int</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a3ff8fd51656a9b577fda3b6e6dfe2719">camWidth</a>, <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a763a796497b5e5aeb1864edb1071e824">camHeight</a>;
<a name="l00049"></a>00049 
<a name="l00051"></a>00051         <span class="comment">// ! Az alkalmazas indulasakor hivodik meg. Called when the activity is first created.</span>
<a name="l00052"></a>00052         <span class="comment">/*</span>
<a name="l00053"></a>00053 <span class="comment">         * ! \param Bundle osztaly, a mentett allapot</span>
<a name="l00054"></a>00054 <span class="comment">         */</span>
<a name="l00055"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0dda6aa746834b7bbcadf59844acd4ef">00055</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0dda6aa746834b7bbcadf59844acd4ef">onCreate</a>(Bundle savedInstanceState) {
<a name="l00056"></a>00056                 super.onCreate(savedInstanceState);
<a name="l00057"></a>00057                 this.requestWindowFeature(Window.FEATURE_NO_TITLE);
<a name="l00058"></a>00058                 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
<a name="l00059"></a>00059                                 WindowManager.LayoutParams.FLAG_FULLSCREEN);
<a name="l00060"></a>00060                 setContentView(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.layout.main);
<a name="l00061"></a>00061                 <a class="code" href="classhelper_1_1_file_i_o_helper.html">FileIOHelper</a>.<a class="code" href="classhelper_1_1_file_i_o_helper.html#ac57a540a93e5542a5792c3c565abf0fd">newFolder</a>(<span class="stringliteral">&quot;/PhysiTrack&quot;</span>);
<a name="l00062"></a>00062                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a865e52bbd221d0d65db95fd6cd546cc1">paramsSet</a> = <span class="keyword">false</span>;
<a name="l00063"></a>00063                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a58f4e0f0217f5e433a17b783685142a1">isRunning</a> = <span class="keyword">false</span>;
<a name="l00064"></a>00064                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a785d9fc51a9c8c87240c4ae205059286">preview</a> = (SurfaceView) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.cameraView);
<a name="l00065"></a>00065                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7d8d556b1784c753d9eb8a00d17a1f91">previewHolder</a> = <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a785d9fc51a9c8c87240c4ae205059286">preview</a>.getHolder();
<a name="l00066"></a>00066                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7d8d556b1784c753d9eb8a00d17a1f91">previewHolder</a>.addCallback(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a396c51868dc513ede508b2bd6150ede3">surfaceCallback</a>);
<a name="l00067"></a>00067                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7d8d556b1784c753d9eb8a00d17a1f91">previewHolder</a>.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
<a name="l00068"></a>00068 
<a name="l00069"></a>00069                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a617b59df0d824c57437a251319483107">text2</a> = (EditText) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.accelerationField);
<a name="l00070"></a>00070                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a73c500622aa06734e6fad1ffba8f6658">text1</a> = (EditText) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.velocityField);
<a name="l00071"></a>00071                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a73c500622aa06734e6fad1ffba8f6658">text1</a>.setHint(<span class="stringliteral">&quot;enter sigmaM&quot;</span>);
<a name="l00072"></a>00072                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a617b59df0d824c57437a251319483107">text2</a>.setHint(<span class="stringliteral">&quot;enter sigmaW&quot;</span>);
<a name="l00073"></a>00073                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ab94b854437cfeb03989d7a6f56fe26ec">velText</a> = (TextView) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.velocityText);
<a name="l00074"></a>00074                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7b5933e7c10aa164e811c74740d75cca">accText</a> = (TextView) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.accelerationText);
<a name="l00075"></a>00075                 Button startCalc = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.startButton);
<a name="l00076"></a>00076                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a> = <span class="keyword">new</span> <a class="code" href="classimage_1_1_analyzer.html">Analyzer</a>(0, 0);
<a name="l00077"></a>00077                 startCalc.setOnClickListener(<span class="keyword">new</span> OnClickListener() {
<a name="l00078"></a>00078 
<a name="l00079"></a>00079                         @Override
<a name="l00080"></a>00080                         <span class="keyword">public</span> <span class="keywordtype">void</span> onClick(View v) {
<a name="l00081"></a>00081                                 <span class="keywordflow">if</span> (!<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a58f4e0f0217f5e433a17b783685142a1">isRunning</a>) {
<a name="l00082"></a>00082                                         <span class="keywordflow">try</span> {
<a name="l00083"></a>00083                                                 <span class="keywordflow">if</span> (!<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a865e52bbd221d0d65db95fd6cd546cc1">paramsSet</a>) {
<a name="l00084"></a>00084                                                         String text = <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a73c500622aa06734e6fad1ffba8f6658">text1</a>.getText().toString();
<a name="l00085"></a>00085                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#abca21fd83ce7631d66f85a7247ac59c3">sigmaM</a> = Double.parseDouble(text);
<a name="l00086"></a>00086                                                         text = <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a617b59df0d824c57437a251319483107">text2</a>.getText().toString();
<a name="l00087"></a>00087                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a03d60fc5556bf34d1a74ac507d2d7010">sigmaW</a> = Double.parseDouble(text);
<a name="l00088"></a>00088                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a865e52bbd221d0d65db95fd6cd546cc1">paramsSet</a> = <span class="keyword">true</span>;
<a name="l00089"></a>00089                                                         LinearLayout rlayout1 = (LinearLayout) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.info);
<a name="l00090"></a>00090                                                         rlayout1.setVisibility(View.VISIBLE);
<a name="l00091"></a>00091                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ab94b854437cfeb03989d7a6f56fe26ec">velText</a>.setText(<span class="stringliteral">&quot;velocity&quot;</span>);
<a name="l00092"></a>00092                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7b5933e7c10aa164e811c74740d75cca">accText</a>.setText(<span class="stringliteral">&quot;acceleration&quot;</span>);
<a name="l00093"></a>00093                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ab94b854437cfeb03989d7a6f56fe26ec">velText</a>.setVisibility(View.VISIBLE);
<a name="l00094"></a>00094                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7b5933e7c10aa164e811c74740d75cca">accText</a>.setVisibility(View.VISIBLE);
<a name="l00095"></a>00095                                                         
<a name="l00096"></a>00096                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a> = <span class="keyword">new</span> <a class="code" href="classimage_1_1_analyzer.html">Analyzer</a>(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#abca21fd83ce7631d66f85a7247ac59c3">sigmaM</a>, <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a03d60fc5556bf34d1a74ac507d2d7010">sigmaW</a>);
<a name="l00097"></a>00097                                                         
<a name="l00098"></a>00098                                                 }
<a name="l00099"></a>00099                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a6fe7bd9c0bde97a16cea6146278551d2">timestamp</a> = System.currentTimeMillis();
<a name="l00100"></a>00100                                                 Button about = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.aboutButton);
<a name="l00101"></a>00101                                                 about.setClickable(<span class="keyword">false</span>);
<a name="l00102"></a>00102                                                 Button diag = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.diagramButton);
<a name="l00103"></a>00103                                                 diag.setClickable(<span class="keyword">false</span>);
<a name="l00104"></a>00104                                                 Button startCalc = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.startButton);
<a name="l00105"></a>00105                                                 startCalc.setText(<span class="stringliteral">&quot;Stop&quot;</span>);
<a name="l00106"></a>00106                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a>.<a class="code" href="classimage_1_1_analyzer.html#aeeeded10f0840612115d8d9f0ba6b809">start</a>();
<a name="l00107"></a>00107                                                 <a class="code" href="classprocess_1_1_proc_im.html">ProcIm</a>.<a class="code" href="classprocess_1_1_proc_im.html#aa2d560699665fb9cb628106b55ece557">init</a>();
<a name="l00108"></a>00108                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.setPreviewCallback(<span class="keyword">new</span> PreviewCallback() {
<a name="l00109"></a>00109 
<a name="l00110"></a>00110                                                         <span class="keyword">public</span> <span class="keywordtype">void</span> onPreviewFrame(byte[] data,
<a name="l00111"></a>00111                                                                         Camera <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>) {
<a name="l00112"></a>00112 
<a name="l00113"></a>00113                                                                 Camera.Parameters parameters = camera
<a name="l00114"></a>00114                                                                                 .getParameters();
<a name="l00115"></a>00115 
<a name="l00116"></a>00116                                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a3ff8fd51656a9b577fda3b6e6dfe2719">camWidth</a> = parameters.getPreviewSize().width;
<a name="l00117"></a>00117                                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a763a796497b5e5aeb1864edb1071e824">camHeight</a> = parameters.getPreviewSize().height;
<a name="l00118"></a>00118                                                                 <span class="keywordtype">long</span> t = System.currentTimeMillis() - <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a6fe7bd9c0bde97a16cea6146278551d2">timestamp</a>;
<a name="l00119"></a>00119                                                                 <a class="code" href="classimage_1_1_own_image.html">OwnImage</a> image = <span class="keyword">new</span> <a class="code" href="classimage_1_1_own_image.html">OwnImage</a>(<a class="code" href="classprocess_1_1_proc_im.html">ProcIm</a>
<a name="l00120"></a>00120                                                                                 .makeBitmap(data, <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a3ff8fd51656a9b577fda3b6e6dfe2719">camWidth</a>, <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a763a796497b5e5aeb1864edb1071e824">camHeight</a>),
<a name="l00121"></a>00121                                                                                 t);
<a name="l00122"></a>00122 
<a name="l00123"></a>00123                                                                 <span class="keywordflow">try</span> {
<a name="l00124"></a>00124                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a>.<a class="code" href="classimage_1_1_analyzer.html#af29c9038cf7b1b8e4fefe9a404f57f20">updateFromFrame</a>(image);
<a name="l00125"></a>00125                                                                         String V = Double.toString(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a>
<a name="l00126"></a>00126                                                                                         .getVelocity());
<a name="l00127"></a>00127                                                                         String A = Double.toString(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a>
<a name="l00128"></a>00128                                                                                         .getAcceleration());
<a name="l00129"></a>00129                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a73c500622aa06734e6fad1ffba8f6658">text1</a>.setText(V);
<a name="l00130"></a>00130                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a617b59df0d824c57437a251319483107">text2</a>.setText(A);
<a name="l00131"></a>00131 
<a name="l00132"></a>00132                                                                 } <span class="keywordflow">catch</span> (<a class="code" href="classprocess_1_1_image_error_exception.html">ImageErrorException</a> e) {
<a name="l00133"></a>00133                                                                         AlertDialog alertDialog = <span class="keyword">new</span> AlertDialog.Builder(
<a name="l00134"></a>00134                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this).create();
<a name="l00135"></a>00135                                                                         alertDialog.setMessage(e.getMessage());
<a name="l00136"></a>00136                                                                         alertDialog.show();
<a name="l00137"></a>00137                                                                         camera.setPreviewCallback(null);
<a name="l00138"></a>00138                                                                         findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.startButton)
<a name="l00139"></a>00139                                                                                         .performClick();
<a name="l00140"></a>00140                                                                 }
<a name="l00141"></a>00141 
<a name="l00142"></a>00142                                                         }
<a name="l00143"></a>00143 
<a name="l00144"></a>00144                                                 });
<a name="l00145"></a>00145 
<a name="l00146"></a>00146                                         } <span class="keywordflow">catch</span> (NumberFormatException e) {
<a name="l00147"></a>00147                                                 AlertDialog alertDialog = <span class="keyword">new</span> AlertDialog.Builder(
<a name="l00148"></a>00148                                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this).create();
<a name="l00149"></a>00149                                                 alertDialog.setMessage(<span class="stringliteral">&quot;Type the parameters!&quot;</span>);
<a name="l00150"></a>00150                                                 alertDialog.show();
<a name="l00151"></a>00151                                         }
<a name="l00152"></a>00152                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a58f4e0f0217f5e433a17b783685142a1">isRunning</a> = <span class="keyword">true</span>;
<a name="l00153"></a>00153                                 } <span class="keywordflow">else</span> {
<a name="l00154"></a>00154                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.setPreviewCallback(null);
<a name="l00155"></a>00155                                         Button diag = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.diagramButton);
<a name="l00156"></a>00156                                         diag.setClickable(<span class="keyword">true</span>);
<a name="l00157"></a>00157                                         Button about = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.aboutButton);
<a name="l00158"></a>00158                                         about.setClickable(<span class="keyword">true</span>);
<a name="l00159"></a>00159                                         Button startCalc = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.startButton);
<a name="l00160"></a>00160                                         startCalc.setText(<span class="stringliteral">&quot;Start&quot;</span>);
<a name="l00161"></a>00161                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a58f4e0f0217f5e433a17b783685142a1">isRunning</a> = <span class="keyword">false</span>;
<a name="l00162"></a>00162                                 }
<a name="l00163"></a>00163 
<a name="l00164"></a>00164                         }
<a name="l00165"></a>00165 
<a name="l00166"></a>00166                 });
<a name="l00167"></a>00167                 Button about = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.aboutButton);
<a name="l00168"></a>00168                 about.setOnClickListener(<span class="keyword">new</span> OnClickListener() {
<a name="l00169"></a>00169 
<a name="l00170"></a>00170                         @Override
<a name="l00171"></a>00171                         <span class="keyword">public</span> <span class="keywordtype">void</span> onClick(View v) {
<a name="l00172"></a>00172                                 Intent intent = <span class="keyword">new</span> Intent(
<a name="l00173"></a>00173                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this,
<a name="l00174"></a>00174                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_about_activity.html">AboutActivity</a>.class);
<a name="l00175"></a>00175                                 startActivity(intent);
<a name="l00176"></a>00176                         }
<a name="l00177"></a>00177                 });
<a name="l00178"></a>00178 
<a name="l00179"></a>00179                 Button diagram = (Button) findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.diagramButton);
<a name="l00180"></a>00180                 diagram.setOnClickListener(<span class="keyword">new</span> OnClickListener() {
<a name="l00181"></a>00181 
<a name="l00182"></a>00182                         @Override
<a name="l00183"></a>00183                         <span class="keyword">public</span> <span class="keywordtype">void</span> onClick(View arg0) {
<a name="l00184"></a>00184                                 AlertDialog.Builder builder = <span class="keyword">new</span> AlertDialog.Builder(
<a name="l00185"></a>00185                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this);
<a name="l00186"></a>00186                                 builder.setMessage(
<a name="l00187"></a>00187                                                 <span class="stringliteral">&quot;In order to view diagrams you have to save the current data\nSave data?&quot;</span>)
<a name="l00188"></a>00188                                                 .setCancelable(<span class="keyword">true</span>)
<a name="l00189"></a>00189                                                 .setPositiveButton(<span class="stringliteral">&quot;Yes&quot;</span>,
<a name="l00190"></a>00190                                                                 <span class="keyword">new</span> DialogInterface.OnClickListener() {
<a name="l00191"></a>00191                                                                         <span class="keyword">public</span> <span class="keywordtype">void</span> onClick(DialogInterface dialog,
<a name="l00192"></a>00192                                                                                         <span class="keywordtype">int</span> <span class="keywordtype">id</span>) {
<a name="l00193"></a>00193                                                                                 dialog.cancel();
<a name="l00194"></a>00194                                                                                 <span class="keyword">final</span> Dialog savedialog = <span class="keyword">new</span> Dialog(
<a name="l00195"></a>00195                                                                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a9ae029040989828ac44bdc544e3c0d14">context</a>);
<a name="l00196"></a>00196                                                                                 savedialog
<a name="l00197"></a>00197                                                                                                 .setContentView(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.layout.savefile);
<a name="l00198"></a>00198                                                                                 savedialog.setTitle(<span class="stringliteral">&quot;Result&quot;</span>);
<a name="l00199"></a>00199 
<a name="l00200"></a>00200                                                                                 <span class="keyword">final</span> EditText filename = (EditText) savedialog
<a name="l00201"></a>00201                                                                                                 .findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.filename);
<a name="l00202"></a>00202 
<a name="l00203"></a>00203                                                                                 Button save = (Button) savedialog
<a name="l00204"></a>00204                                                                                                 .findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.saveButton);
<a name="l00205"></a>00205                                                                                 save.setOnClickListener(<span class="keyword">new</span> OnClickListener() {
<a name="l00206"></a>00206                                                                                         <span class="keyword">public</span> <span class="keywordtype">void</span> onClick(View v) {
<a name="l00207"></a>00207                                                                                                 String name = filename
<a name="l00208"></a>00208                                                                                                                 .getText().toString();
<a name="l00209"></a>00209                                                                                                 <span class="keywordflow">try</span> {
<a name="l00210"></a>00210                                                                                                         <a class="code" href="classhelper_1_1_file_i_o_helper.html">FileIOHelper</a>
<a name="l00211"></a>00211                                                                                                                         .<a class="code" href="classhelper_1_1_file_i_o_helper.html#a3d8f7c5f530b9e68a9495ca6f0e25e67">writeToFile</a>(name,
<a name="l00212"></a>00212                                                                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a>,
<a name="l00213"></a>00213                                                                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a3ff8fd51656a9b577fda3b6e6dfe2719">camWidth</a>,
<a name="l00214"></a>00214                                                                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a763a796497b5e5aeb1864edb1071e824">camHeight</a>);
<a name="l00215"></a>00215                                                                                                         Intent intent = <span class="keyword">new</span> Intent(
<a name="l00216"></a>00216                                                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this,
<a name="l00217"></a>00217                                                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_diagram_activity.html">DiagramActivity</a>.class);
<a name="l00218"></a>00218                                                                                                         intent.putExtra(
<a name="l00219"></a>00219                                                                                                                         <span class="stringliteral">&quot;filepath&quot;</span>,
<a name="l00220"></a>00220                                                                                                                         <a class="code" href="classhelper_1_1_file_i_o_helper.html">FileIOHelper</a>
<a name="l00221"></a>00221                                                                                                                                         .getFullPath(name));
<a name="l00222"></a>00222                                                                                                         intent.putExtra(
<a name="l00223"></a>00223                                                                                                                         <span class="stringliteral">&quot;cameraWidth&quot;</span>,
<a name="l00224"></a>00224                                                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a3ff8fd51656a9b577fda3b6e6dfe2719">camWidth</a>);
<a name="l00225"></a>00225                                                                                                         intent.putExtra(
<a name="l00226"></a>00226                                                                                                                         <span class="stringliteral">&quot;cameraHeight&quot;</span>,
<a name="l00227"></a>00227                                                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a763a796497b5e5aeb1864edb1071e824">camHeight</a>);
<a name="l00228"></a>00228                                                                                                         savedialog.dismiss();
<a name="l00229"></a>00229                                                                                                         startActivity(intent);
<a name="l00230"></a>00230                                                                                                 } <span class="keywordflow">catch</span> (IOException e) {
<a name="l00231"></a>00231                                                                                                         AlertDialog alertDialog = <span class="keyword">new</span> AlertDialog.Builder(
<a name="l00232"></a>00232                                                                                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this)
<a name="l00233"></a>00233                                                                                                                         .create();
<a name="l00234"></a>00234                                                                                                         alertDialog.setMessage(<span class="stringliteral">&quot;Error:&quot;</span>
<a name="l00235"></a>00235                                                                                                                         + e.getMessage());
<a name="l00236"></a>00236                                                                                                         alertDialog.show();
<a name="l00237"></a>00237                                                                                                 }
<a name="l00238"></a>00238 
<a name="l00239"></a>00239                                                                                         }
<a name="l00240"></a>00240                                                                                 });
<a name="l00241"></a>00241 
<a name="l00242"></a>00242                                                                                 Button cancel = (Button) savedialog
<a name="l00243"></a>00243                                                                                                 .findViewById(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_r.html">R</a>.id.cancelButton);
<a name="l00244"></a>00244                                                                                 cancel.setOnClickListener(<span class="keyword">new</span> OnClickListener() {
<a name="l00245"></a>00245                                                                                         <span class="keyword">public</span> <span class="keywordtype">void</span> onClick(View v) {
<a name="l00246"></a>00246                                                                                                 savedialog.dismiss();
<a name="l00247"></a>00247                                                                                                 Intent intent = <span class="keyword">new</span> Intent(
<a name="l00248"></a>00248                                                                                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this,
<a name="l00249"></a>00249                                                                                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_file_chooser.html">FileChooser</a>.class);
<a name="l00250"></a>00250                                                                                                 startActivity(intent);
<a name="l00251"></a>00251 
<a name="l00252"></a>00252                                                                                         }
<a name="l00253"></a>00253                                                                                 });
<a name="l00254"></a>00254 
<a name="l00255"></a>00255                                                                                 savedialog.show();
<a name="l00256"></a>00256                                                                         }
<a name="l00257"></a>00257                                                                 })
<a name="l00258"></a>00258                                                 .setNegativeButton(<span class="stringliteral">&quot;No&quot;</span>,
<a name="l00259"></a>00259                                                                 <span class="keyword">new</span> DialogInterface.OnClickListener() {
<a name="l00260"></a>00260                                                                         <span class="keyword">public</span> <span class="keywordtype">void</span> onClick(DialogInterface dialog,
<a name="l00261"></a>00261                                                                                         <span class="keywordtype">int</span> <span class="keywordtype">id</span>) {
<a name="l00262"></a>00262                                                                                 dialog.cancel();
<a name="l00263"></a>00263                                                                                 Intent intent = <span class="keyword">new</span> Intent(
<a name="l00264"></a>00264                                                                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this,
<a name="l00265"></a>00265                                                                                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_file_chooser.html">FileChooser</a>.class);
<a name="l00266"></a>00266                                                                                 startActivity(intent);
<a name="l00267"></a>00267 
<a name="l00268"></a>00268                                                                         }
<a name="l00269"></a>00269                                                                 });
<a name="l00270"></a>00270                                 <span class="keywordflow">if</span> (!<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ac43f36801eb4b716f1d6f7a5732f56aa">analyzer</a>.<a class="code" href="classimage_1_1_analyzer.html#a77aba9d4fdf0e28a0a510fb6661b52aa">isSaved</a>()) {
<a name="l00271"></a>00271                                         AlertDialog alert = builder.create();
<a name="l00272"></a>00272                                         alert.show();
<a name="l00273"></a>00273                                 } <span class="keywordflow">else</span>
<a name="l00274"></a>00274                                         startActivity(<span class="keyword">new</span> Intent(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html">PhysiTrackActivity</a>.this,
<a name="l00275"></a>00275                                                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_file_chooser.html">FileChooser</a>.class));
<a name="l00276"></a>00276 
<a name="l00277"></a>00277                         }
<a name="l00278"></a>00278                 });
<a name="l00279"></a>00279 
<a name="l00280"></a>00280         }
<a name="l00281"></a>00281 
<a name="l00282"></a>00282         @Override
<a name="l00283"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a88d10285dfbb6909c2228216cc3aa67a">00283</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a88d10285dfbb6909c2228216cc3aa67a">onStart</a>() {
<a name="l00284"></a>00284                 Log.d(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a4c5e235b8006f00cc5c3b9cf6cfd287c">TAG</a>, <span class="stringliteral">&quot;start application&quot;</span>);
<a name="l00285"></a>00285 
<a name="l00286"></a>00286                 super.onStart();
<a name="l00287"></a>00287         }
<a name="l00288"></a>00288 
<a name="l00289"></a>00289         @Override
<a name="l00290"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ae7dba421ae2e839a06143ff259054aa5">00290</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#ae7dba421ae2e839a06143ff259054aa5">onStop</a>() {
<a name="l00291"></a>00291                 Log.d(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a4c5e235b8006f00cc5c3b9cf6cfd287c">TAG</a>, <span class="stringliteral">&quot;stop application&quot;</span>);
<a name="l00292"></a>00292 
<a name="l00293"></a>00293                 super.onStop();
<a name="l00294"></a>00294         }
<a name="l00295"></a>00295 
<a name="l00296"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a761c450eae19598eaf881cb13b8eb965">00296</a>         <span class="keyword">private</span> Camera.Size <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a761c450eae19598eaf881cb13b8eb965">getBestPreviewSize</a>(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height,
<a name="l00297"></a>00297                         Camera.Parameters parameters) {
<a name="l00298"></a>00298                 Camera.Size result = null;
<a name="l00299"></a>00299                 <span class="keywordflow">for</span> (Camera.Size size : parameters.getSupportedPreviewSizes()) {
<a name="l00300"></a>00300                         <span class="keywordflow">if</span> (size.width &lt;= width &amp;&amp; size.height &lt;= height) {
<a name="l00301"></a>00301                                 <span class="keywordflow">if</span> (result == null) {
<a name="l00302"></a>00302                                         result = size;
<a name="l00303"></a>00303                                 } <span class="keywordflow">else</span> {
<a name="l00304"></a>00304                                         <span class="keywordtype">int</span> resultArea = result.width * result.height;
<a name="l00305"></a>00305                                         <span class="keywordtype">int</span> newArea = size.width * size.height;
<a name="l00306"></a>00306                                         <span class="keywordflow">if</span> (newArea &gt; resultArea) {
<a name="l00307"></a>00307                                                 result = size;
<a name="l00308"></a>00308                                         }
<a name="l00309"></a>00309                                 }
<a name="l00310"></a>00310                                 Log.d(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a4c5e235b8006f00cc5c3b9cf6cfd287c">TAG</a>, <span class="stringliteral">&quot;&quot;</span> + size.width + <span class="stringliteral">&quot;  &quot;</span> + size.height);
<a name="l00311"></a>00311                         }
<a name="l00312"></a>00312                 }
<a name="l00313"></a>00313                 <span class="keywordflow">return</span> (result);
<a name="l00314"></a>00314         }
<a name="l00315"></a>00315 
<a name="l00316"></a><a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a396c51868dc513ede508b2bd6150ede3">00316</a>         SurfaceHolder.Callback <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a396c51868dc513ede508b2bd6150ede3">surfaceCallback</a> = <span class="keyword">new</span> SurfaceHolder.Callback() {
<a name="l00317"></a>00317                 <span class="keyword">public</span> <span class="keywordtype">void</span> surfaceCreated(SurfaceHolder holder) {
<a name="l00318"></a>00318                         <span class="keywordflow">try</span> {
<a name="l00319"></a>00319                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a> = Camera.open();
<a name="l00320"></a>00320                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.setPreviewDisplay(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a7d8d556b1784c753d9eb8a00d17a1f91">previewHolder</a>);
<a name="l00321"></a>00321 
<a name="l00322"></a>00322                         } <span class="keywordflow">catch</span> (Throwable t) {
<a name="l00323"></a>00323                                 Log.d(<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a4c5e235b8006f00cc5c3b9cf6cfd287c">TAG</a>, <span class="stringliteral">&quot;Exception in setPreviewDisplay()&quot;</span>, t);
<a name="l00324"></a>00324                         }
<a name="l00325"></a>00325                 }
<a name="l00326"></a>00326 
<a name="l00327"></a>00327                 <span class="keyword">public</span> <span class="keywordtype">void</span> surfaceChanged(SurfaceHolder holder, <span class="keywordtype">int</span> format, <span class="keywordtype">int</span> width,
<a name="l00328"></a>00328                                 <span class="keywordtype">int</span> height) {
<a name="l00329"></a>00329 
<a name="l00330"></a>00330                         Camera.Parameters parameters = <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.getParameters();
<a name="l00331"></a>00331                         Camera.Size size = <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a761c450eae19598eaf881cb13b8eb965">getBestPreviewSize</a>(width, height, parameters);
<a name="l00332"></a>00332                         <span class="keywordflow">if</span> (size != null) {
<a name="l00333"></a>00333                                 parameters.setPreviewSize(size.width, size.height);
<a name="l00334"></a>00334                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.setDisplayOrientation(90);
<a name="l00335"></a>00335                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.setParameters(parameters);
<a name="l00336"></a>00336                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.startPreview();
<a name="l00337"></a>00337                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#afda4399ea9ae19db25f1e8f46d4dc39d">inPreview</a> = <span class="keyword">true</span>;
<a name="l00338"></a>00338                         }
<a name="l00339"></a>00339 
<a name="l00340"></a>00340                 }
<a name="l00341"></a>00341 
<a name="l00342"></a>00342                 <span class="keyword">public</span> <span class="keywordtype">void</span> surfaceDestroyed(SurfaceHolder holder) {
<a name="l00343"></a>00343                         <span class="keywordflow">if</span> (<a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#afda4399ea9ae19db25f1e8f46d4dc39d">inPreview</a>) {
<a name="l00344"></a>00344                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.setPreviewCallback(null);
<a name="l00345"></a>00345                                 <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.stopPreview();
<a name="l00346"></a>00346                         }
<a name="l00347"></a>00347                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a>.release();
<a name="l00348"></a>00348                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#a0468592c039797e3fcd4c18acc19ce8d">camera</a> = null;
<a name="l00349"></a>00349                         <a class="code" href="classro_1_1ubbcluj_1_1android_1_1_physi_track_1_1_physi_track_activity.html#afda4399ea9ae19db25f1e8f46d4dc39d">inPreview</a> = <span class="keyword">false</span>;
<a name="l00350"></a>00350                 }
<a name="l00351"></a>00351 
<a name="l00352"></a>00352         };
<a name="l00353"></a>00353 }
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Fri Jun 8 2012 00:07:22 for PhysiTrack by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
